import {
    getStorage
} from '@/utils/auth.js'

const state = {
    userData: getStorage('userInfo'),
    cancelTokenArr: [] // 取消请求token数组
}

const mutations = {
    SAVE_DATA: (state, data) => {
        state.userData = data;
    },
    // pushToken(state, payload) {
    //     state.cancelTokenArr.push(payload.cancelToken)
    // },
    // clearToken({
    //     cancelTokenArr
    // }) {
    //     cancelTokenArr.forEach(item => {
    //         item('路由跳转取消请求')
    //     })
    //     cancelTokenArr = []
    // }
}

const actions = {
    commitSaveData({
        commit
    }, data) {
        console.log(data,1)
        commit('SAVE_DATA', data);
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}